package tiny.soft.com.service.userinfo;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tiny.soft.com.common.util.CollectionUtil;
import tiny.soft.com.entity.UserInfo.po.UserinfoPo;
import tiny.soft.com.entity.UserInfo.vo.UserinfoVo;
import tiny.soft.com.mapper.userinfo.UserInfoMapper;
import tk.mybatis.mapper.entity.Condition;

import java.util.List;

/**
 * @className:UserInfoService
 * @Author: 宋晓虎
 * @Description: ${description}
 * @Date: 2019/12/25 17:49:42
 */

@Component
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    public UserinfoVo getUserInfo(String name){
        Condition condition=new Condition(UserinfoPo.class);
        condition.createCriteria().andEqualTo("username",name);
        List<UserinfoPo> userinfoPos = userInfoMapper.selectByCondition(condition);
        UserinfoVo userinfoVo=new UserinfoVo();
        if(CollectionUtil.isNotEmpty(userinfoPos)){
            BeanUtils.copyProperties(userinfoPos.get(0),userinfoVo);
            return userinfoVo;
        }
        return userinfoVo;
    }
}
